from django.db import models
from datetime import datetime

#导入django user表
from django.contrib.auth.models import AbstractUser
# Create your models here.

class UserProfile(AbstractUser):
    '''继承用户表
    '''
    nick_name = models.CharField(max_length=50,verbose_name='昵称',default='')
    briday = models.DateField(verbose_name='生日',null=True,blank=True)
    gender = models.CharField(max_length=12,choices=(("male","男"),("female","女")),default='男')
    address = models.CharField(max_length=128,default='')
    mobile = models.CharField(max_length=64,null=True,blank=True)
    image = models.ImageField(max_length=256,upload_to="image/%Y/%m",default="image/default.png")
    class Meta:
        verbose_name = '用户信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

class EmailVerifyRecord(models.Model):
    '''邮箱以及验证码'''
    code = models.CharField(max_length=20,verbose_name="验证码")
    email = models.EmailField(max_length=64,verbose_name='邮箱')
    send_type = models.CharField(max_length=20,choices=(('register','注册'),('forget','忘记密码')))
    send_time = models.DateTimeField(default=datetime.now)

    class Meta:
        verbose_name = '邮箱验证码'
        verbose_name_plural = verbose_name

class Banner(models.Model):
    title = models.CharField(max_length=100,verbose_name='标题')
    image = models.ImageField(max_length=128,upload_to="banner/%Y/%m",verbose_name='轮播图')
    url = models.URLField(max_length=200,verbose_name='访问地址')
    index = models.IntegerField(default=100,verbose_name='顺序')
    add_time = models.DateTimeField(default=datetime.now,verbose_name='添加时间')

    class Meta:
        verbose_name = '轮播图'
        verbose_name_plural = verbose_name